package com.webmuseum.server;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.webmuseum.client.CardInfo;
import com.webmuseum.client.WebMuseumService;

public class WebMuseumServiceImpl extends RemoteServiceServlet implements WebMuseumService 
{	
	
	private Database databases = new Database();
	
	
	
	public void insertQuery(List<String> queries){
		
		
		int nextMainRef=-1;
		try {
			nextMainRef = databases.getMaxID(GeneralDataSetting.mainTableName, GeneralDataSetting.mainTableCounter);
		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		nextMainRef++;
		System.out.println(nextMainRef);

		//for(int i = 0; i< queries.size();++i){
		
			queries.set(0,queries.get(0).replace("MAIN_COUNTER",String.valueOf(nextMainRef)));
			System.out.println(queries.get(0));
			try {
				databases.InsertQuery(queries.get(0));
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		//}
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	public WebMuseumServiceImpl()
	{
		
	}



	
	
	

}
